﻿using iTFF.WPF.CP;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iTFF.WPF.Model.lastfm;
using System.Resources;

namespace iTFF.Tests
{
    
    
    /// <summary>
    ///This is a test class for LastfmControlPanelTest and is intended
    ///to contain all LastfmControlPanelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class LastfmControlPanelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for APIKey
        ///</summary>
        [TestMethod()]
        [DeploymentItem("iTFF.WPF.exe")]
        public void APIKeyTest()
        {
            LastfmControlPanel_Accessor target = new LastfmControlPanel_Accessor(); // TODO: Initialize to an appropriate value
            Assert.AreEqual("bf438bdb9b74c8a5219db6334a775ad3 ", target.APIKey);
        }

        /// <summary>
        ///A test for GetArtistInfo
        ///</summary>
        [TestMethod()]
        public void GetArtistInfoTest()
        {
            LastfmControlPanel target = new LastfmControlPanel();

            var expected = new lastfmArtistInfo()
            {
                Artist = "Incubus",
                Url = "http://www.last.fm/music/Incubus",
                ImageLargeURL = "http://userserve-ak.last.fm/serve/126/176008.jpg",
                Biography = Resources.Resource.lastfmArtistInfoBiography
            };

            TestInfoArtist(expected, target.GetArtistInfo("Incubus"));
            TestInfoArtist(expected, target.GetArtistInfo("incubus"));
            TestInfoArtist(expected, target.GetArtistInfo("   incubus  "));
        }

        private void TestInfoArtist(lastfmArtistInfo expected, lastfmArtistInfo actual)
        {
            Assert.AreEqual(expected.Artist, actual.Artist);
            Assert.AreEqual(expected.Url, actual.Url);
            Assert.AreEqual(expected.ImageLargeURL, actual.ImageLargeURL);
            Assert.AreEqual(expected.Biography, actual.Biography);
        }
    }
}
